package com.csdj.controller.Be;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.csdj.common.enums.AppHttpCodeEnum;
import com.csdj.common.utils.ResponseResult;
import com.csdj.pojo.BeFormula;
import com.csdj.pojo.BeOrderuser;
import com.csdj.service.BeFormulaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/beFormula")
public class BeFormulaController {
    @Autowired
    private BeFormulaService beFormulaService;

    /**
     * 根据用户id获取工单用户提壁纸
     */
    @GetMapping
    public ResponseResult getById(@RequestBody List<BeOrderuser> orderByUser){
        List<BeFormula> list=new ArrayList<>();
        for (int i = 0; i < orderByUser.size(); i++) {
            LambdaQueryWrapper<BeFormula> l=new LambdaQueryWrapper<>();
            l.eq(BeFormula::getOrderUserID,orderByUser.get(i).getID());
            BeFormula byId = beFormulaService.getById(l);
            list.add(byId);
        }
        return !list.isEmpty()?ResponseResult.okResult(list):ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR,"服务器错误,获取用户提鼻梁");
    }
}
